package helper

import (
	"fmt"
	"git.inedcn.com/ined/cmn"
	"rongyy/src/middlewares"
	"time"
)

func ConvertToDateFormat(date cmn.JsonTime) (string, error) {
	str := date.String()
	const Layout = "2006-01-02 15:04:05"
	loc, err := time.LoadLocation("Asia/Shanghai")
	t, err := time.ParseInLocation(Layout, str, loc)
	if err != nil {
		middlewares.Logger.Println("time parse error", err)
		return "", fmt.Errorf("time parse error")
	}
	w := t.Format("2006-01-02")
	return w, nil
}
